<template>
    <div>
		<div class="content">
		    <div class="loginWrap">
		        <h3>系统登录</h3>
		        <div class="login">
		            <ul>
                        <li class="userName">
                            <input type="text" @keyup.enter="handleLogin" v-model="loginForm.name" autoComplete="on" placeholder="用户名">
                        </li>
                        <li class="userPwd"><input type="password" @keyup.enter="handleLogin" v-model="loginForm.password" autoComplete="on" placeholder="密码"></li>
                    </ul>
                    <div>
                        <p class="tl autoLogin">
                        </p>
                        <p class="errorInfo" id='errorInfo'>{{errmsg}}</p>
                        <input class="sbtn" type="submit" @click="handleLogin" value="登 录" >
                    </div>
		        </div>
		    </div>
		</div>
    </div>
</template>

<script>
    import { isWscnEmail } from 'utils/validate';
    var AV = require('leancloud-storage');
    import  munes  from 'mock/mune';
    import md5 from 'js-md5';
    export default {
      name: 'login',
      data() {
        const validatePass = (rule, value, callback) => {
          if (value.length < 6) {
            callback(new Error('密码不能小于6位'));
          } else {
            callback();
          }
        };
        return {
            errmsg:'',
            loginForm: {
                name: '',
                password: ''
            },
            loginRules: {
                name: [
                    { required: true, trigger: 'blur',  message: '请输入用户名' }
                ],
                password: [
                    { required: true, trigger: 'blur', validator: validatePass }
                ]
            },
            loading: false
        }
      },
      methods: {
        handleLogin() {
            this.$store.dispatch("SET_USER_DATA", {
                token:'',
                userName:'',
                roleName:'',
                roleuuids:'',
                uuid:'',
                roleCode:'',
                realname:''
            });
            this.$store.dispatch('SET_MENUS', munes)
            this.$router.push({ path: '/' });
            // let parm = this.loginForm;
            // if (parm.name.length == 0) {
            //     this.errmsg = '请输入用户名'
            //     return ;
            // }
            // if (parm.password.length < 6) {
            //     this.errmsg = '密码不能小于6位'
            //     return ;
            // }
            // parm.password = md5(parm.password)
            // this.Api.auth.login(parm).then((data)=>{
            //     if(data.code == this.Api.resultCode.SUSS){
            //         let m = data.data.res;
            //         this.$store.dispatch("SET_USER_DATA", {
            //             token:data.data.token,
            //             userName:data.data.user.name,
            //             roleName:data.data.user.roleName,
            //             roleuuids:data.data.user.roleuuids,
            //             uuid:data.data.user.uuid,
            //             roleCode:data.data.user.roleCode,
            //             realname:data.data.user.realname,
            //             partnerUuid:data.data.user.partner_uuid
            //         });
            //         this.$store.dispatch('SET_MENUS',m)
            //         this.$router.push({ path: '/' });

            //         this.getRongyunToken(data.data.user.uuid);
            //     }
            // });
            
        }
      }
    }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>


</style>
